<template>
    <div class="sidebar">
        <el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="collapse" background-color="#6c1b08"
            text-color="#bfcbd9" active-text-color="#20a0ff" unique-opened router>
            <template v-for="item in items">
                <template v-if="item.subs">
                    <el-submenu :index="item.index" v-if= "item.types==typess" :key="item.index">
                        <template #title>
                            <i :class="item.icon"></i>
                            <span>{{ item.title }}</span>
                        </template>
                        <template v-for="subItem in item.subs">
                            <el-submenu v-if="subItem.subs" :index="subItem.index" :key="subItem.index">
                                <template #title>{{ subItem.title }}</template>
                                <el-menu-item v-for="(threeItem, i) in subItem.subs" :key="i" :index="threeItem.index">
                                    {{ threeItem.title }}</el-menu-item>
                            </el-submenu>
                            <el-menu-item v-else :index="subItem.index" :key="subItem.index">{{ subItem.title }}
                            </el-menu-item>
                        </template>
                    </el-submenu>
                </template>
                <template v-else>
                    <el-menu-item :index="item.index" v-if= "item.types==typess"  :key="item.index">
                        <i :class="item.icon"></i>
                        <template #title>{{ item.title }}</template>
                    </el-menu-item>
                </template>
            </template>
        </el-menu>
    </div>
</template>

<script>
import { computed, watch } from "vue";
import { useStore } from "vuex";
import { useRoute } from "vue-router";
export default {
    setup() {
        const items = [
            // {
            //     icon: "el-icon-lx-home",
            //     index: "/dashboard",
            //     title: "系统首页",
            //
            // },
            // {
            //     icon: "el-icon-lx-cascades",
            //     index: "/table",
            //     title: "基础表格",
            // },
            // {
            //     icon: "el-icon-lx-copy",
            //     index: "/tabs",
            //     title: "tab选项卡",
            // },
            // {
            //     icon: "el-icon-lx-calendar",
            //     index: "3",
            //     title: "表单相关",
            //     subs: [
            //         {
            //             index: "/form",
            //             title: "基本表单",
            //         },
            //         {
            //             index: "/upload",
            //             title: "文件上传",
            //         },
            //         {
            //             index: "4",
            //             title: "三级菜单",
            //             subs: [
            //                 {
            //                     index: "/editor",
            //                     title: "富文本编辑器",
            //                 },
            //             ],
            //         },
            //     ],
            // },
            // {
            //     icon: "el-icon-lx-emoji",
            //     index: "/icon",
            //     title: "自定义图标",
            //     types:'manager',
            // },
            // {
            //     icon: "el-icon-lx-warn",
            //     index: "7",
            //     title: "错误处理",
            //     subs: [
            //         {
            //             index: "/permission",
            //             title: "权限测试",
            //         },
            //         {
            //             index: "/404",
            //             title: "404页面",
            //         },
            //     ],
            // },
            {
                icon: "el-icon-lx-group",
                index: "8",
                title: "人员管理",
                types:"manager",
                subs: [
                    {
                        index: "/DoctorList",
                        title: "医生管理",
                    },
                    {
                        index: "/reception",
                        title: "前台管理",
                    },
                    {
                        index: "/MPatientList",
                        title: "用户管理",
                    },
                ]
            },
            {
                icon: "el-icon-lx-forward",
                index: "/chooseDepartment",
                title: "挂号",
                types:"patient"
            },
            {
                icon: "el-icon-lx-text",
                index: "/orderList",
                title: "挂号详情",
                types:"patient"
            },
            {
                icon: "el-icon-lx-attentionfill",
                index: "/personalCase",
                title: "个人病历",
                types:"patient"
            },
            {
                icon: "el-icon-lx-recharge",
                index: "/patientPay",
                title: "个人缴费",
                types:"patient"
            },
            {
                icon: "el-icon-lx-sort",
                index: "/patientList",
                title: "挂号列表",
                types:"doctor"
            },
            {
                icon: "el-icon-lx-forward",
                index: "/GetQueue",
                title: "线下挂号",
                types:"reception"
            },
            {
                icon: "el-icon-lx-sort",
                index: "/patientCaseList",
                title: "患者列表",
                types:"reception"
            },
            {
                icon: "el-icon-lx-home",
                index: "/drugManagement",
                title: "药库管理",
                types:"reception"
            },
            {
                icon: "el-icon-lx-cascades",
                index: "/ManageDepartment",
                title: "科室管理",
                types:"manager"
            },

            {
                icon: "el-icon-lx-home",
                index: "/News_Manager",
                title: "新闻管理",
                types:"manager"
            },
            {
                icon: "el-icon-lx-home",
                index: "/drugManagement",
                title: "药库管理",
                types:"manager"
            },
            {
                icon: "el-icon-lx-cart",
                index: "/drugInput",
                title: "药品入库",
                types:"manager"
            },
            {
                icon: "el-icon-lx-rank",
                index: "/StandingBook",
                title: "台账查看",
                types:"manager"
            },

        ];

        const route = useRoute();

        const typess=localStorage.getItem("typess");
        const onRoutes = computed(() => {
            return route.path;
        });

        const store = useStore();
        const collapse = computed(() => store.state.collapse);

        return {
            items,
            onRoutes,
            collapse,
            typess,
        };
    },
};
</script>

<style scoped>
.sidebar {
    display: block;
    position: absolute;
    left: 0;
    top: 70px;
    bottom: 0;
    overflow-y: scroll;

}
.sidebar::-webkit-scrollbar {
    width: 0;
}
.sidebar-el-menu:not(.el-menu--collapse) {
    width: 250px;
}
.sidebar > ul {
    height: 100%;
}
</style>
